from fastapi import APIRouter

from .login import login_with_access_token, send_sms_code, login_with_sms, wx_login, register
from .user import get_user_info, delete_user, search_users, user_join_group, update_user
from .user_group import get_list_group, post_add_group, delete_group, get_list_group_users, \
    update_group_info, group_delete_user, get_list_group_permission, set_group_expiration_time, \
    add_group_resource, get_group_resource_list
from .permission import admin_add_user, admin_update_user, add_permission_to_group, remove_permission_from_group, get_user_permissions

router = APIRouter()

# login
router.post("/login", tags=["User"], summary="登陆")(login_with_access_token)
router.post("/login/wx_login")(wx_login)
router.post("/sms/send", tags=["User"], summary="发送短信验证码")(send_sms_code)
router.post("/sms/login", tags=["User"], summary="短信验证码登陆")(login_with_sms)
router.post("/register", tags=["User"], summary="注册用户")(register)


# user
router.get("/user/get_user_info", tags=["User"], summary="获取用户信息")(get_user_info)
router.post("/user/delete_user", tags=["User"], summary="删除用户")(delete_user)
router.post("/user/search_users", tags=["User"], summary="搜索用户")(search_users)
router.post("/user_join_group", tags=["User"], summary="用户加入组")(user_join_group)
router.post("/user/update_user", tags=["User"], summary="更新用户信息")(update_user)
# router.get("/user/read_user_company", tags=["User"], summary="读取用户公司信息")(read_user_company)
# router.put("/user/update_user_company", tags=["User"], summary="更新用户公司信息")(update_user_company)


# user group
router.get("/group/list_groups", tags=["User Group"], summary="获取用户组")(get_list_group)
router.get("/group/list_group_users", tags=["User Group"], summary="获取组内用户列表")(get_list_group_users)
router.post("/group/add_group", tags=["User Group"], summary="新增用户组")(post_add_group)
router.post("/group/delete_group", tags=["User Group"], summary="删除用户组")(delete_group)
router.post("/group/update_group", tags=["User Group"], summary="更新用户组信息")(update_group_info)


# user permission
router.get("/admin/list_user_permission", tags=["User"], summary="获取用户权限列表")(get_user_permissions)
router.post("/admin/add_user", tags=["Admin"], summary="管理员添加用户")(admin_add_user)
router.post("/admin/update_user", tags=["Admin"], summary="管理员更新用户")(admin_update_user)
router.post("/admin/add_permission", tags=["Admin"], summary="管理员添加权限")(add_permission_to_group)
router.post("/admin/delete_permission", tags=["Admin"], summary="管理员删除权限")(remove_permission_from_group)

router.put("/permission/set_group_expiration_time", tags=["Permission"], summary="设置组过期时间")(set_group_expiration_time)
# group permission
router.get("/list_group_resource", tags=["Permission"], summary="获取组资源列表")(get_group_resource_list)
router.post("/permission/add_group_resource", tags=["Permission"], summary="绑定用户组资源")(add_group_resource)
router.post("/group_delete_user", tags=["Permission"], summary="从组中删除用户")(group_delete_user)
router.get("/permission/list_group_permission", tags=["Permission"], summary="获取组权限列表")(get_list_group_permission)


